package com.doone.telmarket.domain;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * 
 * @author 吴同庆
 * @date 2009-9-16
 * @description 增值业务页面对象
 * @package     com.doone.telmarket.domain
 */
public class ServicePage implements Serializable {

	private static final long serialVersionUID = -1266241135334595668L;

	//增值业务对象
	private Service service;

	//推荐级别
	private Integer recommandGrade;

	//页面可编辑内容列表
	private List<ServicePageContent> contents = new ArrayList<ServicePageContent>();

	//业务订购
	private ServiceOrder serviceOrder;

	private String pageLogoPath;

	private String pageSmallIconPath;

	private String pageFlashPath;

	private String pageUrl;
	
	private String serviceSummaryContent;

	public Service getService() {
		return service;
	}

	public void setService(Service service) {
		this.service = service;
	}

	public Integer getRecommandGrade() {
		return recommandGrade;
	}

	public void setRecommandGrade(Integer recommandGrade) {
		this.recommandGrade = recommandGrade;
	}




	public ServicePage() {

	}

	public ServicePage(Service service, Integer recommandGrade, SiteResource smallIcon, SiteResource logo,
			SiteResource flash, SiteResource page,String serviceSummaryContent) {
		this.service = service;
		this.recommandGrade = recommandGrade;
		pageFlashPath = getSiteResourcePath(flash);
		pageSmallIconPath = getSiteResourcePath(smallIcon);
		pageUrl = getSiteResourcePath(page);
		pageLogoPath = getSiteResourcePath(logo);
		serviceOrder = new ServiceOrder();
		this.serviceSummaryContent = serviceSummaryContent;
	}

	private String getSiteResourcePath(SiteResource resource) {
		return resource.getFullPath();
	}

	public String getPageLogoPath() {
		return pageLogoPath;
	}

	public void setPageLogoPath(String pageLogoPath) {
		this.pageLogoPath = pageLogoPath;
	}

	public String getPageSmallIconPath() {
		return pageSmallIconPath;
	}

	public void setPageSmallIconPath(String pageSmallIconPath) {
		this.pageSmallIconPath = pageSmallIconPath;
	}

	public String getPageFlashPath() {
		return pageFlashPath;
	}

	public void setPageFlashPath(String pageFlashPath) {
		this.pageFlashPath = pageFlashPath;
	}

	public String getPageUrl() {
		return pageUrl;
	}

	public void setPageUrl(String pageUrl) {
		this.pageUrl = pageUrl;
	}

	public void addContent(String title, String content) {
		ServicePageContent pageContent = new ServicePageContent(title, content, this);
		getContents().add(pageContent);
	}

	public void removeContent(String title) {
		for (int i = 0; i < getContentSize(); i++) {
			ServicePageContent content = getContent(i);
			if (content.getTitle().equals(title)) {
				getContents().remove(i);
			}

		}
	}

	public List<ServicePageContent> getContents() {
		return contents;
	}

	public int getContentSize() {
		return getContents().size();
	}

	public ServicePageContent getContent(int index) {
		return getContents().get(index);
	}

	public void setContents(List<ServicePageContent> contents) {
		this.contents = contents;
	}

	public Integer getServiceCode() {
		return getService().getServiceCode();
	}

	public ServiceOrder getServiceOrder() {
		return serviceOrder;
	}

	public void setServiceOrder(ServiceOrder serviceOrder) {
		this.serviceOrder = serviceOrder;
	}

	public String getServiceSummaryContent() {
		return serviceSummaryContent;
	}

	public void setServiceSummaryContent(String serviceSummaryContent) {
		this.serviceSummaryContent = serviceSummaryContent;
	}

}
